package com.tensquare.qa.dao;

import com.tensquare.qa.pojo.Problem;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface ProblemDao extends JpaRepository<Problem,String>,JpaSpecificationExecutor<Problem> {

    //1.查询最新问题列表
    @Query(nativeQuery = true,
            value = "select * from tb_problem,tb_pl where problemid=id and labelid=?1 order by createtime desc"
    )
    Page<Problem> findNewList(String labelid, Pageable pageable);

    //1.查询热门问题列表
    @Query(nativeQuery = true,
            value = "select * from tb_problem,tb_pl where problemid=id and labelid=?1 order by reply desc"
    )
    Page<Problem> findHotList(String labelid, Pageable pageable);
}
